#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
int main()
{
	int a = 0;
	int b = 0;
	int z = 0;
	scanf("%d %d", &a, &b);
	for (int i = 1; i <= ((a < b) ? a : b); i++)
	{
		if ((a % i == 0) && (b % i == 0))
			z = i;
	}
	printf("%d\n", z);

	return 0;
}